<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <!--{include file='comm/header.tpl'}-->
        <title>呼叫中心</title>
        <style type="text/css">
            html {overflow-x:auto; overflow-y:hidden;} /*用来隐藏html的滚动条*/
            body {
                margin:0;  /* 必须 */
                height:100%; /* 必须 */
                overflow-y:auto;/* 必须 */
            }
            table.ebsig-text tr {
                height: 40px;
            }
        </style>
    </head>
    <body>
        <div class="container">
            <div>
                <div style="width:100%; height:auto;">
                    <div>
                        <div>
                            <table border="0" cellspacing="0" cellpadding="0" style="margin: 0; padding:0;border-collapse: collapse; width:auto;">
                                <tbody><tr>
                                    <td>
                                        <input type="button" class="btn btn-default" id="btnCcicLogin" value="登录" onclick="btnCcicLoginClick()">
                                        <!--监听功能暂不使用
                                        <input type="button" class="btn btn-default" id="btnCcicdoSpy" value="监听" onclick="btndoSpyClick()">-->
                                    </td>
                                    <td style=" width:auto">
                                        <iframe width="1050" height="33" name="toolbar" id="toolbar" scrolling="no" frameborder="0" src="/quanliadmin/app/callcenter/callcenter.pscript?operFlg=3" style="border: solid 1px #ddd; overflow:hidden;"></iframe>
                                    </td>
                                </tr>
                                </tbody></table>
                            <div style=" margin-bottom:0px;"></div>

                            <script type="text/javascript">
                                function callout(tel) {
                                    var params = { };
                                    params.tel = document.getElementById('tel').value;
                                    params.callType = '3'; //3点击外呼
                                    document.getElementById("toolbar").contentWindow.executeAction("doPreviewOutCall", params);
                                }
                                function login() { //登录
                                    var params = { };
                                    params.hotLine = document.getElementById('hotLine').value;
                                    params.cno = document.getElementById('cno').value;
                                    E.setCookie('cno', document.getElementById('cno').value, 8640000, '<!--{$ebsig_comm.website.cookie_domain}-->');

                                    //E.setCookie("cno",document.getElementById('cno').value);
                                    params.pwd = document.getElementById('pwd').value;
                                    params.bindTel = document.getElementById('bindTel').value;
                                    E.setCookie('bindTel', document.getElementById('bindTel').value, 8640000, '<!--{$ebsig_comm.website.cookie_domain}-->');

                                    //E.setCookie("bindTel",document.getElementById('bindTel').value);
                                    params.bindType = document.getElementById('bindType').value;
                                    params.initStatus = document.getElementById('initStatus').value;
                                    if (params.bindType == "3") {
                                        params.sipIp = document.getElementById('sipIp').value;
                                        params.sipPwd = document.getElementById('sipPwd').value;
                                    }
                                    document.getElementById("toolbar").contentWindow.executeAction('doLogin', params); //执行登录 ccic2里面的js类
                                    E.popup.close();
                                }
                                function logout() { //登出
                                    var params = { };
                                    params.type = 1;
                                    //add by allen.qiang 20140917 退出时 解除绑定电话--start
                                    params.removeBinding='1';
                                    //add by allen.qiang 20140917 退出时 解除绑定电话--end
                                    document.getElementById("toolbar").contentWindow.executeAction('doLogout', JSON.stringify(params));
                                }
                                function cbLogin(token) { //登录
                                    if (token.code == "0") {
                                        document.getElementById("btnCcicLogin").value = "注销"; ;
                                        var params = { };
                                        params.eventName = 'online';
                                        document.getElementById("toolbar").contentWindow.cbThisStatus(params);
                                    } else {
                                        alert("登录失败！" + token.msg);
                                    }
                                }
                                function readyLoad(d) {

                                }
                                function cbLogout(token) { //退出
                                    if (token.code == "0") {
                                        // document.getElementById("toolbar").src = 'toolbarIframe.html?type=bs';
                                    }
                                }

                                function btnCcicLoginClick() {
                                    var hbtnCcicLogin = document.getElementById("btnCcicLogin");
                                    if (hbtnCcicLogin) {
                                        if (hbtnCcicLogin.value == "登录") {

                                            var html = '<div class="form-horizontal">';

                                            html += '<div class="form-group">';
                                            html += '<label for="custName" class="col-sm-3 control-label">热线号码：</label>';
                                            html += '<div class="col-sm-9">';
                                            html += '<input type="text" class="form-control w150" id="hotLine" placeholder="请输入热线号码" value="4006678678" >';
                                            html += '</div>';
                                            html += '</div>';

                                            html += '<div class="form-group">';
                                            html += '<label for="cno" class="col-sm-3 control-label">座席号：</label>';
                                            html += '<div class="col-sm-9">';
                                            var cno_str;
                                            if(E.getCookie("cno")==null)
                                                cno_str="";
                                            else
                                                cno_str=E.getCookie("cno");
                                            html += '<input type="text" class="form-control w150" id="cno" placeholder="请输入座席号" value="' + cno_str + '" >';
                                            html += '</div>';
                                            html += '</div>';

                                            html += '<div class="form-group">';
                                            html += '<label for="pwd" class="col-sm-3 control-label">密码：</label>';
                                            html += '<div class="col-sm-9">';
                                            html += '<input type="password" class="form-control w150" id="pwd" placeholder="请输入密码" value="" >';
                                            html += '</div>';
                                            html += '</div>';

                                            html += '<div class="form-group">';
                                            html += '<label for="bindTel" class="col-sm-3 control-label">绑定电话：</label>';
                                            html += '<div class="col-sm-9">';
                                            var bindTel_str;
                                            if(E.getCookie("bindTel")==null)
                                                bindTel_str="";
                                            else
                                                bindTel_str=E.getCookie("bindTel");
                                            html += '<input type="text" class="form-control w150" id="bindTel" placeholder="请输绑定电话" value="' + bindTel_str + '" >';
                                            html += '</div>';
                                            html += '</div>';

                                            html += '<div class="form-group">';
                                            html += '<label for="bindType" class="col-sm-3 control-label">电话类型：</label>';
                                            html += '<div class="col-sm-9">';
                                            html += '<select class="form-control w150" id="bindType">';
                                            html += '<option value="1">电话号码</option>';
                                            html += '<option value="2">分机号码</option>';
                                            html += '<option value="3">软电话</option>';
                                            html += '</select>';
                                            html += '</div>';
                                            html += '</div>';

                                            html += '<div class="form-group">';
                                            html += '<label for="initStatus" class="col-sm-3 control-label">初始状态：</label>';
                                            html += '<div class="col-sm-9">';
                                            html += '<select class="form-control w150" id="initStatus">';
                                            html += '<option value="online">空闲</option>';
                                            html += '<option value="pause">置忙</option>';
                                            html += '</select>';
                                            html += '</div>';
                                            html += '</div>';

                                            html += '</div>';

                                            E.popup.open({
                                                title: '登录',
                                                content: html,
                                                btnName: '登录',
                                                css: 'width: 500px;',
                                                btnCall: "login()"
                                            });

                                        } else {
                                            hbtnCcicLogin.value = "登录";
                                            logout();
                                        }
                                    }
                                }
                                //add by allen.qiang20140923 增加监听功能
                                //功能暂不用
                                function btndoSpyClick() {
                                    var hbtnCcicdoSpy = document.getElementById("btnCcicdoSpy");
                                    if (hbtnCcicdoSpy) {
                                        if (btnCcicdoSpy.value == "监听") {

                                            var html = '<div class="form-horizontal">';

                                            html += '<div class="form-group">';
                                            html += '<label for="bindTel" class="col-sm-3 control-label">目标座席号：</label>';
                                            html += '<div class="col-sm-9">';

                                            html += '<input type="text" class="form-control w150" id="TspCno" placeholder="目标座席号" value="" >';
                                            html += '</div>';
                                            html += '</div>';

                                            html += '</div>';

                                            E.popup.open({
                                                title: '监听',
                                                content: html,
                                                btnName: '监听',
                                                css: 'width: 500px;',
                                                btnCall: "doSpyClick()"
                                            });

                                        } else {
                                            btnCcicdoSpy.value = "取消监听";
                                            doUnspyClick();
                                        }
                                    }
                                }
                                //取消监听
                                //功能暂不用
                                function doUnspyClick(){
                                    var params={};
                                    params.spyObject = doSpyCno;
                                    document.getElementById("toolbar").contentWindow.executeAction("doUnspy",  JSON.stringify(params));
                                }
                                //取消监听回调
                                //功能暂不用
                                function cbUnspy(json) {
                                    var msg;
                                    switch(json.code)
                                    {
                                        case "0":
                                            msg="取消座席"+doSpyCno + "监听成功";
                                            break;
                                        case "2":
                                            msg=doSpyCno +"座席连接已中断";
                                            break;
                                        case "5":
                                            msg=doSpyCno +"座席不在通话";
                                            break;
                                        case "12":
                                            msg="状态错误";
                                            break;
                                        default:
                                            msg="异常错误";
                                    }
                                    alert(msg);
                                    document.getElementById("btnCcicdoSpy").value="监听";
                                }
                                var doSpyCno;
                                //监听
                                //功能暂不用
                                function doSpyClick(){
                                    doSpyCno= document.getElementById("TspCno").value;
                                    var params = {};
                                    params.spyObject = E.getCookie("cno");
                                    params.objectType = '1';
                                    params.spiedCno = doSpyCno;
                                    document.getElementById("toolbar").contentWindow.executeAction('doSpy', JSON.stringify(params));
                                    E.popup.close();//关闭层
                                }
                                //监听回调
                                //功能暂不用
                                function cbSpy(json) {
                                    //0：成功，
                                    //2：连接已中断，
                                    //5：座席不在通话，
                                    //11：状态错误，
                                    //12：没有此座席，
                                    //21：座席已被监控，
                                    //22：班长不能监控正在做监控的其他班长席
                                    var msg;
                                    switch(json.code)
                                    {
                                        case "0":
                                            msg="座席"+doSpyCno + "监听成功";
                                            document.getElementById("btnCcicdoSpy").value="取消监听";
                                            break;
                                        case "2":
                                            msg="连接已中断";
                                            break;
                                        case "5":
                                            msg=doSpyCno +"座席不在通话";
                                            break;
                                        case "11":
                                            msg="状态错误";
                                            break;
                                        case "12":
                                            msg="没有此座席" + doSpyCno;
                                            break;
                                        case "21":
                                            msg==doSpyCno +"座席已被监控";
                                            break;
                                        case "22":
                                            msg="班长不能监控正在做监控的其他班长席";
                                            break;
                                        default:
                                            msg="异常错误";
                                    }
                                    alert(msg);
                                }
                            </script>
                        </div>
                    </div>
                </div>
                <!--{if isset($sign) && $sign != ""}-->
                    <button type="button" class="btn btn-primary" style="float: right;margin:4px 126px 0px 0px;" onclick="history.go(-1)">返回上一级</button>
                <!--{/if}-->
            </div>

            <ul class="nav nav-tabs">
                <li class="active" mobile=""><a href="javascript: void(0);">默认</a></li>
            </ul>

            <div id="iframe_box">
                <!--{if isset($billPlatform)}-->
                    <iframe id="tab-iframe" style="width: 100%; height: 440px;" border="0" frameborder="0" marginwidth="0" marginheight="0" name="呼叫中心" src="/quanliadmin/app/callcenter/callcenter.pscript?operFlg=2&billPlatform=<!--{$billPlatform}-->&operateType=<!--{$operateType}-->"></iframe>
                <!--{elseif isset($operateType)}-->
                    <iframe id="tab-iframe" style="width: 100%; height: 440px;" border="0" frameborder="0" marginwidth="0" marginheight="0" name="呼叫中心" src="/quanliadmin/app/callcenter/callcenter.pscript?operFlg=2&operateType=<!--{$operateType}-->"></iframe>
                <!--{else}-->
                    <iframe id="tab-iframe" style="width: 100%; height: 440px;" border="0" frameborder="0" marginwidth="0" marginheight="0" name="呼叫中心" src="/quanliadmin/app/callcenter/callcenter.pscript?operFlg=2"></iframe>
                <!--{/if}-->
            </div>
        </div>
        <script type="text/javascript">
            var old_mobile = '';
            $(window).ready(function() {
                $(document).on('click', '.nav-tabs li', function() {
                    var mobile = $(this).attr('mobile');
                    var index = $(this).index();
                    if (old_mobile == mobile) {
                        return false;
                    }
                    old_mobile = mobile;
                    $('.nav-tabs li').removeClass('active').eq(index).addClass('active');
                    $('.nav-tabs li i').hide();
                    if (index > 0) {
                        $(this).find('i').show();
                    }
                    $('#tab-iframe').attr('src', '/quanliadmin/app/callcenter/callcenter.pscript?operFlg=2&mobile=' + mobile);

                });

                $(document).on('click', '.nav-tabs li i', function() {

                    event.stopPropagation();
                    $(this).parent().remove();
                    $('.nav-tabs li').removeClass('active');
                    $('.nav-tabs li').each(function(k, v) {
                        $(v).addClass('active');
                        return false;
                    });
                    $('#tab-iframe').attr('src', '/quanliadmin/app/callcenter/callcenter.pscript?operFlg=2&mobile=');
                });
            });

            function ebsig_come_ringing( customerNumber ) {
                old_mobile = customerNumber;
                $('.nav-tabs li').removeClass('active');
                $('.nav-tabs li i').hide();
                $('.nav-tabs').append('<li class="active" mobile="' + customerNumber + '"><a href="javascript: void(0);">' + customerNumber + '<i class="close-default"></i></a></li>');
                $('#tab-iframe').attr('src', '/quanliadmin/app/callcenter/callcenter.pscript?operFlg=2&mobile=' + customerNumber);
            }
        </script>

    </body>
</html>